﻿using System;

namespace NEnsure.Rules
{
	public class MinValueRule<T> : BaseBusinessRule<T>, IBusinessRule<T> where T : IComparable<T>
	{
		private readonly T _minValue; 

		public override string RuleKey
		{
			get { return "Min-Value Rule"; }
		}

		public MinValueRule(T minValue)
			: base("{value} can't be less than " + minValue)
		{
			_minValue = minValue;
		}

		public bool IsBrokenBy(T value)
		{
			return value.CompareTo(_minValue) < 0;
		}
	}
}
